package stark.app;

import android.app.Application;

import com.stark.amap.AmapSdk;
import com.stark.irremote.lib.net.IRextReqManager;
import com.stark.tbs.lib.TbsInitializer;
import com.stark.thirdlogin.lib.ThirdLoginProxyImpl;
import com.stark.usersysui.lib.event.UserSysEventImpl;

import stark.app.mine.UpgradeManager;
import stark.common.basic.event.thirdlogin.ThirdLoginProxy;
import stark.common.basic.event.thirdlogin.ThirdPlatformType;
import stark.common.basic.event.usersys.UserSysEventProxy;

/**
 * create by fanlc
 * on 2020/10/22
 * description
 */
public class App extends Application {

    public static Application sInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        sInstance = this;
        AmapSdk.init(AppConfig.AMAP_KEY);
        initQbSDK();
        irRemoteInit();
        UpgradeManager.getInstance().init();
        userSysInit();
    }


    /**
     * 步骤一：gradle里面导入依赖
     * 步骤二：通过initQbSDK初始化内核
     * 步骤三：通过QbSDKViewerActivity的startDocumentViewer来启动activity来预览文件
     */
    private void initQbSDK() {
        TbsInitializer.init(this);
    }

    /**
     * 接入万能遥控器库irremote时的初始化动作
     */
    private void irRemoteInit() {
        IRextReqManager.init(AppConfig.IREXT_APP_KEY, AppConfig.IREXT_APP_SECRET);
    }

    private void userSysInit() {
        //将用户系统具体实现类实例设置为代理
        UserSysEventProxy.getInstance().setProxy(new UserSysEventImpl(0));

        //创建第三方登录代理的具体实现类实例
        ThirdLoginProxyImpl thirdLoginProxyImpl = new ThirdLoginProxyImpl(AppConfig.UMENG_ID);
        //添加第三方平台应用配置信息，下面为加入在微信开放平台申请的应用信息
        thirdLoginProxyImpl.addPlatformConfig(ThirdPlatformType.WECHAT, AppConfig.WX_APPID, AppConfig.WX_APP_SECRET);
        //设置为代理
        ThirdLoginProxy.getInstance().setProxy(thirdLoginProxyImpl);

        //请在用户同意隐私政策后调用下面接口进行初始化,这里是demo工程，所以放在了这里
        ThirdLoginProxy.getInstance().init();
    }
}

